define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'zone/account/index' + location.search,
                    add_url: 'zone/account/add',
                    edit_url: 'zone/account/edit',
                    del_url: 'zone/account/del',
                    multi_url: 'zone/account/multi',
                    table: 'account',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                showExport: false,
                exportTypes:['excel'],
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false,visible: false},
                        {field: 'name', title: __('Name'),operate: 'LIKE %...%',placeholder:'模糊搜索'},
                        {field: 'password', title: __('Password'),operate: false,visible:false},
                        // {field: 'question', title: __('Question'),operate: false,visible: false},
                        // {field: 'answer', title: __('Answer'),operate: false,visible: false},
                        // {field: 'email', title: __('Email'),operate: 'LIKE %...%',placeholder: '模糊搜索'},
                        // {field: 'qq', title: __('Qq'),operate: 'LIKE %...%',placeholder: '模糊搜索'},
                        // {field: 'tel', title: __('Tel'),operate: 'LIKE %...%',placeholder: '模糊搜索'},
                        // {field: 'id_type', title: __('Id_type'),operate: false,visible:false},
                        // {field: 'id_card', title: __('Id_card'),operate: false,visible:false},
                        {field: 'point', title: __('Point'),operate: false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});